<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 600px;
            height: 200px;
            margin: 0 auto;
            background-color: red;
            color: white;
            font-size: 20px;
            text-align: center;
            line-height: 200px;
        }
    </style>
</head>
<body>

    <div id="time">
        111111111
    </div>
    <script>
        // // 第二个参数是毫秒时间
        // setTimeout("alert('11111111')",3000)

        function showTime(){
            var d = new Date();
            var year = d.getFullYear();  // 年
            var month = d.getMonth();  // 月
            //日
            var day = d.getDate();

            // 星期
            var week = d.getDay();  // 获取到的是0-6 数字
            var str_week = "";
            switch (week) {
                case 0:
                    str_week = "星期天"
                    break;
                case 1:
                    str_week = "星期一"
                    break;
                case 2:
                    str_week = "星期二"
                    break;
                case 3:
                    str_week = "星期三"
                    break;
                case 4:
                    str_week = "星期四"
                    break;
                case 5:
                    str_week = "星期五"
                    break;
                case 6:
                    str_week = "星期六"
                    break;
                default:
                    break;
            }
            // 时
            var shi = d.getHours();
            //分
            var fen = d.getMinutes();
            //秒
            var miao = d.getSeconds();
            document.getElementById("time").innerHTML = year + "年" + (month+1) + "月" + day + "日" + " " + str_week + " " + shi + ":" + fen + ":"+ miao
        }
        // 定时刷新
        setInterval("showTime()",1000);

    </script>
</body>
</html>